from django.contrib import admin
from .models import Pet

@admin.register(Pet)
class PetAdmin(admin.ModelAdmin):
    list_display = ('name', 'owner', 'age', 'sex', 'breed', 'create_time')  # 添加owner字段
    list_filter = ('sex', 'breed', 'owner')  # 增加按主人筛选
    search_fields = ('name', 'breed', 'owner__username')  # 允许按主人用户名搜索
    ordering = ('-create_time',)
    date_hierarchy = 'create_time'